package com.xm.xmapp.wxapi;

import android.content.Intent;
import android.os.Bundle;

import com.tencent.mm.sdk.constants.ConstantsAPI;
import com.tencent.mm.sdk.modelbase.BaseReq;
import com.tencent.mm.sdk.modelbase.BaseResp;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.xm.xmapp.app.CodeConstant;
import com.xm.xmapp.base.BaseActivity;
import com.xm.xmapp.tools.PayUitl;
import com.xm.xmapp.tools.Tools;

public class WXPayEntryActivity extends BaseActivity implements IWXAPIEventHandler {
	private IWXAPI api;
	/**
	 * 当前状态
	 */
	public static int currentStatus;// 当前状态
	/**
	 * 长租预约订单支付
	 */
	public static final int LONGYUYUE = 1;// 长租预约订单支付
	/**
	 * 长租续租订单支付
	 */
	public static final int LONGRERENT = 2;// 长租续租订单支付
	// public static final int CHONGZHI = 3;
	/**
	 * tv_button
	 */
	public static final int FENSHIHC = 4;// 分时还车订单支付
	/**
	 * 钱包订单支付
	 */
	public static final int WALLET = 5;// 钱包订单支付
	/**
	 * 充电桩订单支付
	 */
	public static final int PILE = 6;// 充电桩订单支付
	/**
	 * 违章押金订单支付
	 */
	public static final int WZ = 7;// 违章押金订单支付

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// setContentView(R.layout.pay_result);
		api = WXAPIFactory.createWXAPI(this, CodeConstant.APPID);
		api.handleIntent(getIntent(), this);
	}

	@Override
	protected void onNewIntent(Intent intent) {
		super.onNewIntent(intent);
		setIntent(intent);
		api.handleIntent(intent, this);
	}

	@Override
	public void onReq(BaseReq req) {
	}

	@Override
	public void onResp(BaseResp resp) {

		finish();
		if (resp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
			if (resp.errCode == 0) {
				PayUitl.getInstence().afterPayMoney();
			}
			if (resp.errCode == -1) {
				Tools.showMessage("支付失败");
			}
			if (resp.errCode == -2) {
				Tools.showMessage("用户已取消");
			}
		}

	}

	@Override
	public void initView() {

	}

	@Override
	public void initData() {

	}

	@Override
	public void initEvent() {

	}
}